<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="dbpedia.QueryPedia"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.hp.hpl.jena.query.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>CO-TRANS Sample Page</title>
<h2>Select Interests:</h2>

<form ACTION="index.jsp">
	<input type="checkbox" name="id" value="Social_media"> Social Media<BR>
	<input type="checkbox" name="id" value="Semantic_Web"> Semantic Web<BR>
	<input type="checkbox" name="id" value="Social_networks"> Social Networks<BR>
	<input type="checkbox" name="id" value="Virtual_communities"> Virtual Communities<BR>
	<input type="checkbox" name="id" value="Cloud_standards"> Cloud Standards<BR>
	<input type="submit" value="Submit">
</form>
<%

String select[] = request.getParameterValues("id");
ArrayList<String> a= new ArrayList<String>();

if (select != null && select.length != 0) {
	for (int i = 0; i < select.length; i++) {
		a.add(select[i]); 
	}
	QueryPedia q= new QueryPedia();
	ArrayList<String> res=q.runQuery(a);
	
	out.println("Wikipedia Articles Collected for You: <br><br>");
	Iterator<String> it= res.iterator();
	int i=1;
	while(it.hasNext()){
		String link= it.next();
		out.println(i+". "+"<a href=\""+link+"\">"+link+"</a><br>");
		out.println();
		i++;
	}
}
%>
</html>